import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter, HashRouter } from 'react-router-dom';
import { ConfigProvider } from 'antd';
import zhCN from 'antd/locale/zh_CN';
import App from './App';
import './index.css';

// 检测是否在Electron环境中
const isElectron = navigator.userAgent.toLowerCase().indexOf('electron') > -1;

const root = ReactDOM.createRoot(
  document.getElementById('root') as HTMLElement
);

// 在Electron中使用HashRouter，在浏览器中使用BrowserRouter
const Router = isElectron ? HashRouter : BrowserRouter;

// React Router v7 future flags
const routerProps = {
  future: {
    v7_startTransition: true,
    v7_relativeSplatPath: true,
  },
};

root.render(
  <React.StrictMode>
    <Router {...routerProps}>
      <ConfigProvider locale={zhCN}>
        <App />
      </ConfigProvider>
    </Router>
  </React.StrictMode>
);
